<script type="text/javascript">
    <!--
        function checkReturnCount(e){
            if (!e){
					if ((event.keyCode<48 || event.keyCode>57) && event.keyCode!=8)
						event.returnValue=false;
			}
			else{
				if ((e.which<48 || e.which>57) && e.which!=8)
					return false;
			}
        }
        function submitForm(){
            if (document.getElementById("returnCount").value><%=@paper_item.current_count%>){
                alert("退货数量不能大于销售数量！");
                document.getElementById("returnCount").value=<%=@paper_item.current_count%>;
            }
            else
                frmReturnPaper.submit();
        }
    -->
</script>
<h1>订单管理 - <span id="secondHeading">填写退货单</span></h1>
<%=@paper_item.salePaper.id%>号订单中<%=@paper_item.product.name%>产品的退货单</p>
<form id="input-form" name="frmReturnPaper" action="/sale/add_return_paper" method="post">
<TABLE border="0" id="INPUT_TABLE">
	<%=hidden_field_tag(:maxCount,@paper_item.current_count.to_i - @return_count.to_i)%>
	<%=hidden_field_tag(:itemId,@paper_item.id)%>
	<%=hidden_field_tag(:product_id,@paper_item.product.id)%>
	<%=hidden_field_tag(:sale_paper_item_id,@paper_item.id)%>
	<%=hidden_field_tag(:price,@paper_item.price)%>
	<TR>
		<TD width="80">产品名称:</TD>
		<TD><%=@paper_item.product.name%></TD>
	</TR>
	<TR>
		<TD>产品编号:</TD>
		<TD><%=@paper_item.product.serial%></TD>
	</TR>
	<TR>
		<TD>销售时间:</TD>
		<TD><%=@paper_item.salePaper.sale_date_at%></TD>
	</TR>
	<TR>
		<TD>本单销售数量:</TD>
		<TD><%=@paper_item.current_count%></TD>
	</TR>
	<TR>
		<TD>本单已退货数量:</TD>
		<TD><%=@return_count%></TD>
	</TR>
	<TR>
		<TD>退货数量:</TD>
		<TD><input type="text" id="returnCount" name="returnCount" value="<%=@paper_item.current_count%>" readonly=""/></TD>
	</TR>
        <!--
	<TR>
		<TD>退货产品条形码:</TD>
		<TD><textarea name="number" cols="50" rows="3"></textarea></TD>
	</TR>
        -->
	<TR>
		<TD>退货理由:</TD>
		<TD><textarea name="memo" cols="50" rows="7"></textarea></TD>
	</TR>
	<TR>
	<TD colspan="2" align="right"><input type="button" class="sub" value="提交" onclick="submitForm()"></TD>
	</TR>
</TABLE>
 <p class="note"> <strong class="alert">注意：</strong><br/>
 一、退货产品条形码需要用逗号（,）分隔
 </p>
</form>
<script type="text/javascript">
    //document.getElementById("returnCount").onkeypress=checkReturnCount;
</script>
